package controllers
{
    import com.google.analytics.AnalyticsTracker;
    import com.google.analytics.GATracker;
    
    import flash.display.DisplayObject;
    
    
    /**
     *
     * @author Administrator
     */
    public class UserBehaviorAnalysis
    {
        /**
         *
         */
        public function UserBehaviorAnalysis()
        {
        }
        
        /**
         *
         * @default
         */
        public static var tracker:AnalyticsTracker;
        /**
         *
         * @default
         */
//		private static const GA_ID:String='UA-53307740-1';
        private static const GA_ID:String='UA-55118237-1';
//        private static const GA_ID:String='UA-59525206-1';
        
        /**
         *
         */
        public static function init(view:DisplayObject):void
        {
            tracker = new GATracker( view, GA_ID, "AS3", false); 
        }
        
        /**
         *
         * @param catetory click/collect
         * @param action target
         * @param label uid
         * @param value index
         */
        public static function trackEvent(catetory:String, action:String, label:String='', value:int=0):void
        {
            if (!tracker)
                return;
            tracker.trackEvent(catetory,action,label,value);
        }
        
        /**
         *
         * @param view classname
         */
        public static function trackView(view:String):void
        {
            if (!tracker)
                return;
            tracker.trackPageview(view);
        }
        
        /**
         *
         * @param catetory staytime/tasktime
         * @param value time:ms
         * @param type classname
         */
        public static function trackTime(catetory:String, value:int, type:String):void
        {
            if (!tracker)
                return;
//			tracker.trackEvent(''
//			tracker.buildTiming(catetory, value).withLabel(UID).withName(type).track();
        }
    }
}


